home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000094_icon-group-sender _Fri Apr 22 11:36:51 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  3KB

  1. Received: by cheltenham.cs.arizona.edu; Fri, 22 Apr 1994 12:34:52 MST
  2. Date: Fri, 22 Apr 1994 11:36:51 -0500
  3. From: John David Stone <stone@math.grin.edu>
  4. Message-Id: <199404221636.LAA01303@russell.math.grin.edu>
  5. To: janpeter@mpi.nl
  6. Cc: icon-group@cs.arizona.edu
  7. In-Reply-To: Jan Peter de Ruiter's message of Fri, 22 Apr 1994 13:06:56 +0100 <9404221206.AA25564@mpix10.mpi.kun.nl>
  8. Subject: is this a bug?
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12.         Here's an excerpt from _The Icon Programming Language_, second
  13. edition (pages 76-77), that explains what's going on:
  14.  
  15. -----------------------------------------------------------------------------
  16.         A structure value is reference (pointer) to an aggregate of values.
  17. Furthermore, assignment copies the reference (pointer) but not the
  18. aggregate of values to which it points.  There are several consequences of
  19. these properties of structures that may not be immediately obvious.
  20. Consider
  21.  
  22.                 index := list(50, 0)
  23.                 temp := index
  24.                 temp[1] := 1
  25.  
  26. The assignment of the value of index to temp does not copy the 50 values
  27. pointed to by the value of index.  Instead, index and temp both point to
  28. the _same_ aggregate of values.  Therefore, the assignment of 1 to temp[1]
  29. changes the contents of the list that temp and index share as their value.
  30. The effect is as if
  31.  
  32.                 index[1] := 1
  33.  
  34. had been evaluated. ... Since assignment does not copy structures, the
  35. result of an expression such as
  36.  
  37.                 L1 := L2 := list(i, 0)
  38.  
  39. is to assign the _same_list to both L1 and L2.  Subsequently, assignment to
  40. a position in L2 changes the value of that position in L1, and conversely.
  41. Similarly, the effect of
  42.  
  43.                 L := list(3, list(5, 0))
  44.  
  45. is to assign the _same_ list of five values to each of the three values in
  46. L.
  47. -----------------------------------------------------------------------------
  48.  
  49.         De Ruiter is running up against the same problem; he has the _same_
  50. (initially empty) list as the default value throughout table T1.
  51. Consequently, when a call to put modifies the value of this list, the
  52. effect is to change every entry in the table (because there _is_ actually
  53. only one "aggregate of values" on the other end of all the pointers).
  54.  
  55. ------  John David Stone - Lecturer in Computer Science and Philosophy  -----
  56. --------------  Manager of the Mathematics Local-Area Network  --------------
  57. --------------  Grinnell College - Grinnell, Iowa 50112 - USA  --------------
  58. --------  stone@math.grin.edu - (515) 269-3181 - stone@grin1.bitnet  --------
  59.